﻿<%@ Page Title="" Language="C#" MasterPageFile="~/_console/_console.Master" AutoEventWireup="true"
    CodeBehind="application-add.aspx.cs" Inherits="SmartSpace.WebApp._console.core.application_add" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderHead" runat="server">
    <script src="../javascript/jquery-1.8.0.min.js"></script>

    <script type="text/javascript">
        function checkSpecialStr(str) {
            var bl = true;
            var arr = new Array("@", "#", "$", "%", "&", "|", "\\", "//");
            i = arr.length;
            j = str.length;
            str = $.trim(str);
            if (str == "") {
                bl = true;
            } else {
                for (ii = 0; ii < i; ii++) {
                    for (jj = 0; jj < j; jj++) {
                        temp1 = str.charAt(jj);
                        temp2 = arr[ii];
                        if (temp1 == temp2) {
                            bl = false;
                        }
                    }
                }
            }
            return bl;
        }

        function checkSubmit() {
            var msg = "";
            var suffix = checkSuffix($("#_ctlFileImage").val());
            var str_Name = $("#_ctlEditText").val();
            var str_Copyright = $("#_ctlEditCopyright").val();
            if ($.trim(str_Name).length == 0) {
                msg = "Name is not allow null!";
            }
            if ($.trim(str_Copyright).length == 0) {
                msg = "Copyright is not allow null!";
            }
            if ($.trim(str_Copyright).length != 0 && !checkSpecialStr(str_Copyright)) {
                msg = "Copyright不允许为非法字符!";
            }
            if (suffix == "") {
                msg = "请选择Application图标!";
            }
            if (suffix != "jpg" && suffix != "png" && suffix != "bmp" && suffix != "gif") {
                msg = "请选择jpg,png,bmp,gif格式的图标!";
            }
            if ($.trim(str_Name).length != 0 && !checkSpecialStr(str_Name)) {
                msg = "名称不允许为非法字符!";
            }
            if (msg == "") {
                if (window.confirm("Are you sure to add this information?")) {
                    return true;
                }
                else {
                    return false;
                }
            }
            else {
                alert(msg);
                return false;
            }
        }

        function checkSuffix(str) {
            if (str == "") {
                return "";
            }
            str = str.substring(str.lastIndexOf('.') + 1);
            return str;
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolderMenu" runat="server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="ContentPlaceHolderTitle" runat="server">
    添加新application
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolderToolbar" runat="server">
    <asp:HyperLink ID="_ctlLinkBack" runat="server">返回</asp:HyperLink>
    <asp:LinkButton ID="_ctlBtnSave" runat="server" OnClick="_ctlBtnSave_Click" OnClientClick="return checkSubmit();">保存</asp:LinkButton>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolderContent" runat="server">
    <div class="form">
        <label>
            HostUrl(*)</label><br />
        <asp:TextBox ID="_ctlEditHostUrl" ClientIDMode="Static" runat="server" />
        <br />
        <label>
            名称</label><br />
        <asp:TextBox ID="_ctlEditText" ClientIDMode="Static" runat="server" />
        <br />
        <label>
            图标</label><br />
        <asp:FileUpload ID="_ctlFileImage" ClientIDMode="Static" runat="server" />
        <%--<img style="display: block" id="img1" src="C:\Users\v-penwu\Desktop\Images\Office.png"/>--%>
        <br />
            <label>
                网站模板</label><br />
            <asp:DropDownList ID="_ctlListTemplate" runat="server" DataTextField="Caption" DataValueField="Id">
            </asp:DropDownList>
        <br />
        <em>应用程序的类型</em><br />
        <label>
            Copyright</label><br />
        <asp:TextBox ID="_ctlEditCopyright" ClientIDMode="Static" runat="server"></asp:TextBox><br />
    </div>
</asp:Content>
